package com.aco.party.web.validator.system;

import com.aco.party.web.command.system.EditCompanyCommand;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

/**
 * Created by flying on 3/10/2016 0010.
 */
public class EditCompanyValidator implements Validator {
    @Override
    public boolean supports(Class<?> aClass) {
        return EditCompanyCommand.class.isAssignableFrom(aClass);
    }

    @Override
    public void validate(Object o, Errors errors) {
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "error.name.empty", "公司名称不能为空");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "type", "error.type.empty", "公司类型不能为空");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "area", "error.area.empty", "工作地区不能为空");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "majorBiz", "error.majorBiz.empty", "主营业务不能为空");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "zone", "error.zone.empty", "涉及领域不能为空");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "scale", "error.scale.empty", "公司规模不能为空");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "website", "error.website.empty", "公司官网不能为空");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "discription", "error.discription.empty", "公司简介不能为空");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "seniorManager", "error.seniorManager.empty", "公司高管不能为空");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "address", "error.address.empty", "公司地址不能为空");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "contact", "error.contact.empty", "联系人及电话不能为空");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "iconUrl", "error.iconUrl.empty", "主图不能为空");

    }
}
